import { Component, OnInit } from '@angular/core';
import { Params, ActivatedRoute } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import * as constants from '../../../providers/Constants'
import { ToastService } from './../../../providers/toast/toast.service'
import { NavController } from '@ionic/angular';
import { Storage } from 'src/app/providers/Storage';

@Component({
  selector: 'app-faq',
  templateUrl: './faq.page.html',
  styleUrls: ['./faq.page.scss'],
})
export class FaqPage implements OnInit {
  faqArray:any=[];
  constructor( private nav: NavController, private auth: AuthService, private toast: ToastService) {
 
  }


  onClick(index){
      if (this.faqArray[index].select) {
        this.faqArray[index].select=false;
      }else{
        this.faqArray[index].select=true;
      }
  }
  ngOnInit() {
    this.auth.getUserQuestion({
      param:'1'//1查常见问题 2查投诉
    }).subscribe(res => {
      // 保存成功返沪上一页，否则弹出提示框
      if (res.retCode == '000000') {
        for (let index = 0; index < res.array.length; index++) {
          res.array[index].select=false;
        }
        this.faqArray=res.array;
      }  else if (constants.errCode[res.retCode]) {
        if (constants.errCode[res.retCode] != '0') {
          this.toast.show(constants.errCode[res.retCode]);
        }
      } else if (res.retMsg) {
        this.toast.show(res.retMsg);
      } else {
        this.toast.show("exception service routine");
      }
    });
  }

}
